package com.inch.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/requiredLogin")
public class LoginController {
    @RequestMapping("/login")
    public String login(HttpSession session,String id,String password){
        if(id.equals("spring")&&password.equals("123")) {
            session.setAttribute("login", true);
        } else {
            session.setAttribute("login",false);
        }
        return "redirect:/jsp/loginService.jsp";
    }
    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.setAttribute("login",false);
        return "forward:/jsp/loginService.jsp";
    }
    @RequestMapping("/service1")
    public String service1(){
        System.out.println("service1");
        return "jsp/service1";
    };
    @RequestMapping("/service2")
    public String service2(){
        System.out.println("service2");
        return "jsp/service2";
    };

}
